package org.example.hansp.collection_.exercise;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@SuppressWarnings({"all"})
public class HomeWork02 {
    public static void main(String[] args) {
        ArrayList list = new ArrayList();
        Car bwm = new Car("bwm", 79.9);
        Car xiaomi = new Car("xiaomi", 29.9);
        list.add(bwm);
        list.add(xiaomi);
        System.out.println(list);
        list.remove(0);
        System.out.println(list);
        boolean contains = list.contains(xiaomi);
        System.out.println(contains);
        boolean isEmpty = list.isEmpty();
        System.out.println(isEmpty);
      /*  list.clear();
        System.out.println(list);*/
        List newlist=new ArrayList();
        newlist.add(bwm);
        newlist.add(xiaomi);

        list.addAll(newlist);
        System.out.println(list);

        System.out.println(list.containsAll(newlist));

       /* list.removeAll(newlist);
        System.out.println(list);*/
        for (Object o : list) {
            System.out.println(o);
        }
        System.out.println("=========================");
        Iterator it = list.iterator();
        while (it.hasNext()) {
            Car car = (Car) it.next();
            System.out.println(car);
        }
    }
}
class Car{
    private String name;
    private double price;

    public Car(String name, double price) {
        this.name = name;
        this.price = price;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    @Override
    public String toString() {
        return "Car{" +
                "name='" + name + '\'' +
                ", price=" + price +
                '}';
    }
}